package com.zero.manage.web.utils.generate;

import com.zero.manage.web.components.entity.SysDictEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * Mysql数据库相关操作
 *
 * @author zero
 */
@Repository
public interface MysqlDao extends JpaRepository<SysDictEntity, String> {
    /**
     * 获取数据库名称
     *
     * @return
     */
    @Query(value = "select schema_name from information_schema.schemata", nativeQuery = true)
    List<String> getCatalogs();

    /**
     * 获取数据库表信息
     *
     * @return
     */
    @Query(value = "select table_name tableName,table_comment tableComment from information_schema.tables where table_schema=?1", nativeQuery = true)
    List<Map<Object, Object>> getTableInfo(String catalogs);

}
